package com.gotcha.bootstart.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @time 2020/5/19
 * @auth 郭彬
 * @describe
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.gotcha.bootstart.controller"))
                //.paths(PathSelectors.regex("/rest/article/.*"))//,包内生成文档的部分
                .build();
    }

    private ApiInfo apiInfo(){
        Contact contact = new Contact("Gotcha","https://my.oschina.net/u/2615680","1091427547@qq.com");

        return new ApiInfo(
                "SwaggerAPI文档",
                "XX项目",
                "v1.0",
                "urn:tos",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0"
        );
    }

}
